package com.googlecode.wicketcharts.showcase.options;

import java.awt.Color;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import com.googlecode.wicketcharts.highcharts.options.Center;
import com.googlecode.wicketcharts.highcharts.options.DataLabels;
import com.googlecode.wicketcharts.highcharts.options.DummyOption;
import com.googlecode.wicketcharts.highcharts.options.Marker;
import com.googlecode.wicketcharts.highcharts.options.NamedPoint;
import com.googlecode.wicketcharts.highcharts.options.NamedPointSeriesOptions;
import com.googlecode.wicketcharts.highcharts.options.Options;
import com.googlecode.wicketcharts.highcharts.options.SeriesOptions;
import com.googlecode.wicketcharts.highcharts.options.SeriesType;
import com.googlecode.wicketcharts.highcharts.options.SimpleSeriesOptions;
import com.googlecode.wicketcharts.highcharts.options.Title;
import com.googlecode.wicketcharts.highcharts.options.XAxis;

/**
 * Demo of the same combo chart as in the Highcharts demo at <a
 * href="http://www.highcharts.com/demo/combo"
 * >http://www.highcharts.com/demo/combo</a>.
 * 
 * @author Tom Hombergs (tom.hombergs@gmail.com)
 * 
 */
public class ComboChartOptions extends Options {

	private static final long serialVersionUID = 1L;

	public ComboChartOptions() {
		setTitle(new Title("Combination chart"));

		XAxis xAxis = new XAxis();
		xAxis.setCategories(Arrays.asList(new String[] { "Apples", "Oranges",
				"Pears", "Bananas", "Plums" }));
		setxAxis(xAxis);

		setTooltip(new DummyOption());

		setLabels(new DummyOption());

		SeriesOptions<Number> series1 = new SimpleSeriesOptions();
		series1.setType(SeriesType.COLUMN);
		series1.setName("Jane");
		series1.setData(Arrays.asList(new Number[] { 3, 2, 1, 3, 4 }));

		SeriesOptions<Number> series2 = new SimpleSeriesOptions();
		series2.setType(SeriesType.COLUMN);
		series2.setName("John");
		series2.setData(Arrays.asList(new Number[] { 2, 3, 5, 7, 6 }));

		SeriesOptions<Number> series3 = new SimpleSeriesOptions();
		series3.setType(SeriesType.COLUMN);
		series3.setName("Joe");
		series3.setData(Arrays.asList(new Number[] { 4, 3, 3, 9, 0 }));

		Marker series4Marker = new Marker();
		series4Marker.setLineWidth(2);
		series4Marker.setLineColor(Color.PINK);
		series4Marker.setFillColor(Color.WHITE);

		SeriesOptions<Number> series4 = new SimpleSeriesOptions();
		series4.setType(SeriesType.SPLINE);
		series4.setName("Average");
		series4.setData(Arrays.asList(new Number[] { 3, 2.67, 3, 6.33, 3.33 }));
		series4.setMarker(series4Marker);

		NamedPointSeriesOptions series5 = new NamedPointSeriesOptions();
		series5.setType(SeriesType.PIE);
		series5.setName("Total consumption");
		series5.addPoint(new NamedPoint("Jane", 13, Color.decode("#4572A7")));
		series5.addPoint(new NamedPoint("John", 23, Color.decode("#AA4643")));
		series5.addPoint(new NamedPoint("Joe", 19, Color.decode("#89A54E")));
		series5.setCenter(new Center(100, 80, Center.Unit.PIXELS));
		series5.setSize(100);
		series5.setShowInLegend(Boolean.FALSE);
		series5.setDataLabels(new DataLabels(Boolean.TRUE));

		List<SeriesOptions<?>> seriesList = new ArrayList<SeriesOptions<?>>();
		seriesList.add(series1);
		seriesList.add(series2);
		seriesList.add(series3);
		seriesList.add(series4);
		seriesList.add(series5);
		setSeries(seriesList);
	}

}
